﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MINERP.NewProductBigPic
{
    public partial class FrmColorSetting : Form
    {
        public FrmColorSetting()
        {
            InitializeComponent();
        }

        private void simpleButtonOtherOK_Click(object sender, EventArgs e)
        {
            string RemarkKeysColor = "";
            string key1 = (textBoxkey1.Text.Trim());
            if (!string.IsNullOrEmpty(key1))
            {
                Color c1 = labelRemarkColor1.BackColor;
                RemarkKeysColor += key1 + "@" + c1.R + "," + c1.G + "," + c1.B + "#";

            }
            string key2 = (textBoxkey2.Text.Trim());
            if (!string.IsNullOrEmpty(key2))
            {
                Color c = labelRemarkColor2.BackColor;
                RemarkKeysColor += key2 + "@" + c.R + "," + c.G + "," + c.B + "#";

            }
            string key3 = (textBoxkey3.Text.Trim());
            if (!string.IsNullOrEmpty(key3))
            {
                Color c = labelRemarkColor3.BackColor;
                RemarkKeysColor += key3 + "@" + c.R + "," + c.G + "," + c.B + "#";

            }
            string key4 = (textBoxkey4.Text.Trim());
            if (!string.IsNullOrEmpty(key4))
            {
                Color c = labelRemarkColor4.BackColor;
                RemarkKeysColor += key4 + "@" + c.R + "," + c.G + "," + c.B + "#";

            }
            string key5 = (textBoxkey5.Text.Trim());
            if (!string.IsNullOrEmpty(key5))
            {
                Color c = labelRemarkColor5.BackColor;
                RemarkKeysColor += key5 + "@" + c.R + "," + c.G + "," + c.B + "#";

            }
            string key6 = (textBoxkey6.Text.Trim());
            if (!string.IsNullOrEmpty(key6))
            {
                Color c = labelRemarkColor6.BackColor;
                RemarkKeysColor += key6 + "@" + c.R + "," + c.G + "," + c.B + "#";

            }
            string key7 = (textBoxkey7.Text.Trim());
            if (!string.IsNullOrEmpty(key7))
            {
                Color c = labelRemarkColor7.BackColor;
                RemarkKeysColor += key7 + "@" + c.R + "," + c.G + "," + c.B + "#";

            }
            string key8 = (textBoxkey8.Text.Trim());
            if (!string.IsNullOrEmpty(key8))
            {
                Color c = labelRemarkColor8.BackColor;
                RemarkKeysColor += key8 + "@" + c.R + "," + c.G + "," + c.B + "#";

            }
            //IniFileOper.IniWriteValue("Host", "RemarkKeysColor", RemarkKeysColor.Trim('#'));
            Properties.Settings.Default.RemarkKeysColor = RemarkKeysColor;
            Properties.Settings.Default.Save();
        }
        private void labelRemarkColor1_Click(object sender, EventArgs e)
        {
            SetColor(sender);
        }

        private void labelRemarkColor2_Click(object sender, EventArgs e)
        {
            SetColor(sender);
        }

        private void labelRemarkColor3_Click(object sender, EventArgs e)
        {
            SetColor(sender);
        }

        private void labelRemarkColor4_Click(object sender, EventArgs e)
        {
            SetColor(sender);
        }

        private void labelRemarkColor5_Click(object sender, EventArgs e)
        {
            SetColor(sender);
        }

        private void labelRemarkColor6_Click(object sender, EventArgs e)
        {
            SetColor(sender);
        }

        private void labelRemarkColor7_Click(object sender, EventArgs e)
        {
            SetColor(sender);
        }

        private void labelRemarkColor8_Click(object sender, EventArgs e)
        {
            SetColor(sender);
        }
        void SetColor(object sender)
        {
            colorDialog3.AllowFullOpen = true;
            colorDialog3.FullOpen = true;
            colorDialog3.ShowHelp = true;
            colorDialog3.Color = Color.Black;
            if (DialogResult.OK == colorDialog3.ShowDialog())
            {
                ((Label)sender).BackColor = colorDialog3.Color;
            }

        }

        private void FrmColorSetting_Load(object sender, EventArgs e)
        {
            string RemarkKeysColor = Properties.Settings.Default.RemarkKeysColor.Trim('#');
            string[] colorarray = RemarkKeysColor.Split('#');
            int iCount = 1;
            foreach (string strKV in RemarkKeysColor.Split('#'))
            {
                if (string.IsNullOrEmpty(strKV))
                {
                    continue;
                }
                string[] keysValue = strKV.Split('@');
                int R = Convert.ToInt16(keysValue[1].Split(',')[0]);
                int G = Convert.ToInt16(keysValue[1].Split(',')[1]);
                int B = Convert.ToInt16(keysValue[1].Split(',')[2]);
                switch (iCount)
                {
                    case 1:

                        textBoxkey1.Text = keysValue[0];
                        labelRemarkColor1.BackColor = Color.FromArgb(R, G, B);
                        break;
                    case 2:
                        textBoxkey2.Text = keysValue[0];
                        labelRemarkColor2.BackColor = Color.FromArgb(R, G, B);
                        break;
                    case 3:
                        textBoxkey3.Text = keysValue[0];
                        labelRemarkColor3.BackColor = Color.FromArgb(R, G, B);
                        break;
                    case 4:
                        textBoxkey4.Text = keysValue[0];
                        labelRemarkColor4.BackColor = Color.FromArgb(R, G, B);
                        break;
                    case 5:
                        textBoxkey5.Text = keysValue[0];
                        labelRemarkColor5.BackColor = Color.FromArgb(R, G, B);
                        break;
                    case 6:
                        textBoxkey6.Text = keysValue[0];
                        labelRemarkColor6.BackColor = Color.FromArgb(R, G, B);
                        break;
                    case 7:
                        textBoxkey7.Text = keysValue[0];
                        labelRemarkColor7.BackColor = Color.FromArgb(R, G, B);
                        break;
                    case 8:
                        textBoxkey8.Text = keysValue[0];
                        labelRemarkColor8.BackColor = Color.FromArgb(R, G, B);
                        break;

                }
                iCount++;

            }

        }

    }
}
